<!-- 发文》审批操作》签发页面 -->
<template>
	<view>
		<view class="cu-form-group align-start">
			<textarea class="textarea"  maxlength="-1"  placeholder="请填写签发意见" v-model="qfopinion"></textarea>
		</view>
		<van-loading class="loading" v-show="loadState" color="#0094ff" text-color="#0094ff" size="24px" vertical>数据提交中...</van-loading>
		<view class="sub-btn" >
			<van-button color="#0079fe"   type="info" size="normal" @click="submitOpinion">确定</van-button>
		</view>
	</view>

</template>

<script>
	import sendIndex from 'pages/jgj/send/index'
	export default {
		components: {
			sendIndex
		},
		data() {
			return {
				userInfo:{},//当前登录用户信息，目前先从缓存中获取
				loadState:false,//加载中
				proInstId:'',
				actInstId:'',
				workItemId:'',
				qfopinion:'',//签发意见

			}
		},
      onLoad: async function (option) {
        await this.$onLaunched //解決bug：执行完onLaunch后再执行页面onLoad
			this.userInfo = this.cache.get('userInfo')//从缓存获取用户信息
			//从地址栏获取参数
			console.log("签发-->获取地址栏参数option: " + JSON.stringify(option))
			this.proInstId= option.proInstId
			this.actInstId= option.actInstId
			this.workItemId= option.workItemId
		},
		methods: {
			submitOpinion(){
				// this.$toast(this.qfopinion)
				this.saveopinion()
			},
			//签发
			saveopinion(){
				this.loadState = true
				var _this = this
				this.$http({
				  url: this.$http.adornUrl(`/caac/oa/component/approval/saveopinion?systemKey=`+this.cache.get('userInfo').systemKey+`&systemFlag=`+this.cache.get('userInfo').systemFlag),
				  method: 'post',
				  data: this.$http.adornData({
					  'actInstId': this.actInstId,//
					  'isApproval':'1',//核稿状态，默认传1
					  'opinion':this.qfopinion,
					  'opiniontype':'jldReview',//
					  'proInstId': this.proInstId,//发文详情返回的proInstId
					  'workItemId': this.workItemId//
					  // 'systemKey': 'jb_sun',//固定值
					  // 'systemFlag': 'yidong',//固定值
				  })
				}).then(({data}) => {
					this.loadState = false
					console.log("签发：data-->: " + JSON.stringify(data));
					if(data.code==200){
						_this.$refs.sendIndex.refreshBtnGroup(true)//TODO 调用父页面重新加载数据
						_this.$toast('提交成功')
						//返回到上个页面
						uni.navigateBack({
							animationType: 'pop-out',
							animationDuration: 2000
						})
					}else{
						_this.$toast(data.message+' code:'+data.code)
					}

				})
			},
		},
	}
</script>

<style>
	.cu-form-group{
		border: 2rpx solid #e4e4e4;
		border-radius: 10rpx;
	}
	.textarea{
		margin: 32rpx 0 30rpx;
		height: 300rpx;
		width: 100%;
		line-height: 40rpx;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		font-size: 32rpx;
		padding: 0;


	}
	.sub-btn{
		display: flex;
		flex-direction: row;
		justify-content: center;
		width: 100%;
	}
	.sub-btn .van-button{
		margin-top: 120rpx;
		height: 88rpx;
		width: 260rpx;
		border-radius: 14rpx;
	}
</style>
